import { createApp } from 'vue'
import App from './App.vue'
import router from './router' // 引入 vue-router
import './assets/css/index.css'
import 'animate.css'
// import "/@/utils/websocket"
// import '@bytemd/vue-next/dist/inde'
import { global } from '/@/config/global'
// OpenAPI.BASE="http://101.201.104.148:18003"
// 单独引入 ElMessage 和 ElMessageBox 的样式
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// Object.keys(ElIcon).forEach((key) => {
//   app.component(key, ElIcon[key])
// })
// import 'element-plus/theme-chalk/el-message.css'
// import 'element-plus/theme-chalk/el-message-box.css'
//
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/src/message.scss'
import ElementPlus from 'element-plus'
import 'font-awesome/css/font-awesome.min.css'
// https://pinia.web3doc.top/core-concepts/
// 引入持久化插件
// @ts-ignore
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createPinia } from 'pinia'
import { OpenAPI } from '/@/api/openapi'

const { VITE_APP_BASE_URL } = import.meta.env
console.log(import.meta.env)
OpenAPI.BASE= VITE_APP_BASE_URL
console.log('========main.ts 初始化 正在初始化OpenAPI===================',OpenAPI.BASE)

console.log('========main.ts 初始化 正在删除token 信息(删除本地缓存)===================')
// 移除token信息，方便测试
localStorage.removeItem(global.USER)
localStorage.removeItem(global.USERINFO)

const store = createPinia()
// 将插件提供给store实例
store.use(piniaPluginPersistedstate)
const app = createApp(App)
//icon注册
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}


app.use(store).use(ElementPlus).use(router).mount('#app')
